#ifndef ____DICT_HPP____
#define ____DICT_HPP____
#include<iostream>
#include<unordered_map>
#include<fstream>
#include<string>

const std::string _sep = ": ";

class Dict
{
private:
    void LoadIn()
    {
        std::ifstream in(_path);
        if(!in.is_open())
        {
            return;
        }
        std::string line;
        while(std::getline(in,line))
        {
            size_t pos = line.find(_sep);
            if(pos == std::string::npos)
                continue;

            std::string _Key = line.substr(0,pos);
            std::string _Value = line.substr(pos+ _sep.size());

            _dict.insert({_Key,_Value});
        }
    }
public:
    Dict(const std::string& path)
        :_path(path)
    {
        LoadIn();
    }
    ~Dict()
    {}

    std::string Translate(const std::string& word)
    {
        auto pos = _dict.find(word);
        if(pos == _dict.end())
        {
            return "Unknown";
        }

        return "User find:" + pos->first + " -> " + pos->second;

    }

private:
    std::string _path;
    std::unordered_map<std::string,std::string> _dict;
};






#endif